package socket.udp;

import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.net.*;

public class Send {
    public static void main(String[] args) throws Exception {
        DatagramSocket socket = new DatagramSocket();
        BufferedInputStream bis = new BufferedInputStream(new FileInputStream(new File("F://Test//T1//a.txt")));
        byte[] bytes = new byte[1024];
        int len = 0;
        InetAddress ia = InetAddress.getByName("127.0.0.1");
        int port = 8080;
        DatagramPacket packet;
        while ((len = bis.read(bytes)) != -1) {
            packet = new DatagramPacket(bytes, 0, len, ia, port);
            socket.send(packet);
        }
    }
}
